#!/usr/bin/env/python3.7
# -*- coding: utf-8 -*-

"""
@File    : app_read_excel.py
@Time    : 12/13/2021
@Author  : Silence
@Version : 1.0
@Contact : silence2021silence@163.com
@License : (C)Copyright 2021-2021, Silence
@Desc    : None
"""

import xlrd

class ReadExcel():
    def read_excel(excel_path):
        if excel_path != '':
            data = xlrd.open_workbook(excel_path)
            table = data.sheets()[0]
            rows = table.nrows
            info_list = []
            for row in range(1, rows):
                info = {'ip_address':'',
                        'student_number':'',
                        'name':'',
                        'room':'',
                        'grade':'',
                        'class':''}
                value_1 = table.cell_value(row, 1)
                value_2 = table.cell_value(row, 3)
                info['ip_address'] = table.cell_value(row, 0)
                info['student_number'] = str(value_1).rstrip('.0')
                info['name'] = table.cell_value(row, 2)
                info['room'] = str(value_2).rstrip('.0')
                info['grade'] = table.cell_value(row, 4)
                info['class'] = table.cell_value(row, 5)
                info_list.append(info)
            return info_list

if __name__ == '__main__':
  print(ReadExcel.read_excel())